<?php
$_category = $this->getCurrentCategory();
// $_category = Mage::getModel('catalog/category')->load($_category->getEntityId());
$_children = $_category->getChildrenCategories();
$_catHp    = Mage::helper('catalog/category');
$_catOutHp = Mage::helper('catalog/output');
$index = 0;
$size  = count($_children);
$_productAllCategory = null;
$_selfBrands = null;
$_otherStore = Mage::getModel('catalog/category')->load(Silk_Store_Config_Store::REGION_CITY_CATEGORY_ID);
$_imageList  = Mage::getModel('silk_store/store')->getCurrentWebsiteStoreImageList();
$_existStore = FALSE;
?>

    <div class="all-classification-nav">
    <?php foreach($_children as $child): ?>
        <?php $_selfBrands = $child->getEntityId() == Silk_Store_Config_Store::GREEN_BRANDS_ID ? $child : $_selfBrands ?>
        <?php $_productAllCategory = $index == 0 ? $child : $_productAllCategory ?>
        <div id="category-<?php echo $child->getEntityId() ?>" class="all-classification-catalog all-title <?php echo $index==0?'active':'' ?>"><span><?php echo $child->getName() ?></span></div>
        <?php if($index!=$size-1): ?><div class="all-classification-divider"></div><?php endif ?>
        <?php $index++; ?>
    <?php endforeach ?>
    </div>

    <div class="all_content">
        <div class="all-small-div" style="display: block;">
        <?php if(is_object($_productAllCategory)): ?>
                <?php foreach($_productAllCategory->getChildrenCategories() as $child): ?>
                <h2><?php echo $child->getName() ?></h2>
                <div class="all-small-ul">
                    <ul>
                    <?php foreach($child->getChildrenCategories() as $_child): ?>
                        <li><a href="<?php echo $_catHp->getCategoryUrl($_child) ?>"><?php echo $_child->getName() ?></a></li>
                    <?php endforeach ?>
                    </ul>
                    <div style="clear: both;"></div>
                </div>
                <div class="arrows"> <span class="fa fa-angle-down"></span> </div>
                <?php endforeach ?>
        <?php endif ?>
        </div>
        <?php // green space self brands ?>
        <?php if(is_object($_selfBrands)): ?>
        <div class="all-small-div">
            <ul class="all-small-brand">
            <?php foreach($_selfBrands->getChildrenCategories() as $_child): ?>
                <li><a href="<?php echo $_catHp->getCategoryUrl($_child) ?>"><img alt="<?php echo $_child->getName() ?>" title="<?php echo $_child->getName() ?>" src="<?php echo $_child->load($_child->getEntityId())->getImageUrl() ?>" /></a></li>
            <?php endforeach ?>
            </ul>
        </div>
        <?php endif ?>
        <div class="all-small-div all-small-div-sole">
            <ul class="all-small-merchants">
            <?php
            foreach($_otherStore->getChildrenCategories() as $city): // get city start
                foreach($city->getChildrenCategories() as $region):  // get regin start
                    if($region->hasChildren()): // if have store start
                        foreach($region->getChildrenCategories() as $store): // get store start
            ?>
                <li>
                    <a href="<?php echo $_catHp->getCategoryUrl($store) ?>">
                    <img alt="<?php echo $store->getName() ?>" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $_imageList[$store->getEntityId()] ?>"/>
                    <p><?php echo $store->getName() ?></p>
                    </a>
                </li>
            <?php
                        $_existStore = TRUE;
                        endforeach; // get store end
                    endif; // if have store end
                endforeach; // get regin end
            endforeach; // get city end
            ?>
            <?php if(!$_existStore): ?>
                <li><p><?php echo $this->__('没有对应的商店') ?></p></li>
            <?php endif ?>
            </ul>
        </div>
    </div>
